#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>

#define NORTHWEST (0)
#define NORTH     (1) 
#define NORTHEAST (2)
#define EAST      (3)

#define RUN_A 45  
#define RUN_B 40
#define RUN_C 35
#define RUN_D 30 //*
#define RUN_E 10
#define RUN_F 8
#define RUN_G 6
#define RUN_H 5
#define RUN_I 3
#define RUN_J 1


/*
 * Sum the threats present on the board according to the following scheme
 * 10 points for SRRG SGRR or RRGS or GRRS or ... RUN_A
 * 9 points for S(GGR|RGG) or (GGR|RGG)S RUN_B
 * 8 points for SRGR or RGRS RUN_C
 * 7 points for SGRG or GRGS RUN_D
 * 6 points for RRSS RUN_E
 * 5 points for SRRS RUN_F
 * 4 points for SGRS or SRGS RUN_G
 * 3 points for SRSR or RSRS RUN_H
 * 2 points for RSSG or GSSR or RSGS or GSRS RUN_I
 * and 1 points for SR or RS RUN_J
 * (and the same values but negative for runs with blue)
 */
int threats ( char *board );
int partialruns ( char *board );

int threats_scanCell ( int x, int y, char *board );
int threats_scanEast ( int x, int y, char *board );
int threats_scanNorth ( int x, int y, char *board );
int threats_scanNorthEast ( int x, int y, char *board );
int threats_scanNorthWest ( int x, int y, char *board );

// iterate:
//     - get the next (x,y) pair in a north/northeast/east/northwest scan
//     - x and y contain the current location, and the new location is also written
//       into them
// returns:
//     0 if return value is valid, 1 if edge of board has been hit
int scanUp ( char *board );
int scanRight ( char *board );
int scanUpRight ( char *board );
int scanUpLeft ( char *board );
int runval ( char *run ); 
